#include <stdio.h>
#include "define.h"
#include "main.h"
#include <time.h>
int main() 
{
	int a[ARRAYSIZE];
	int copy_of_a[ARRAYSIZE];
	clock_t clock_quick_1, clock_quick_2;
	clock_t clock_merge_1, clock_merge_2;
	clock_t clock_bubble_1, clock_bubble_2;
	time_t time_quick_1, time_quick_2;
	time_t time_merge_1, time_merge_2;
	time_t time_bubble_1, time_bubble_2;
	int option, steps_quick, steps_merge, steps_bubble;
	read_array(a);
	do_a_copy(a, copy_of_a);
	printf("This is the original array\n");
	print_array(a);
/*	option = menu(); 
	printf("Option = %d\n", option);
*/
	do {
		option = menu(); 
		printf("Option = %d\n", option);
		switch (option){
			case 1:
				do_a_copy(copy_of_a, a);
				selection_sort(a);
				print_array(a);
				break;
			case 2:
				time_bubble_1 = time(NULL);
				clock_bubble_1 = clock();
				do_a_copy(copy_of_a, a);
				steps_bubble = bubble_sort(a);
				time_bubble_2 = time(NULL);
				clock_bubble_2 = clock();
				printf ("\nSteps bubblesort: %d", steps_bubble);
				printf ("\nTime elapsed: %f\n", (float) 
					(clock_bubble_1 - clock_bubble_2));
				printf ("\nTime elapsed: %ld\n", (long) 
					(time_bubble_1 - time_bubble_2)/CLOCKS_PER_SEC);
				print_array(a);
				break;
			case 3:
				time_merge_1 = time(NULL);
				clock_merge_1 = clock();
				do_a_copy(copy_of_a, a);
				steps_merge = merge_sort(a, 0, ARRAYSIZE - 1);
				time_merge_2 = time(NULL);
				clock_merge_2 = clock();
				printf ("\nSteps mergesort: %d", steps_merge);
				printf ("\nTime elapsed: %f\n", (float) 
					(clock_merge_1 - clock_merge_2));
				printf ("\nTime elapsed: %ld\n", (long) 
					(time_merge_1 - time_merge_2)/CLOCKS_PER_SEC);
				print_array(a);
				break;
			case 4:
				time_quick_1 = time(NULL);
				clock_quick_1 = clock();
				do_a_copy(copy_of_a, a);
				steps_quick = quick_sort(a, 0, ARRAYSIZE - 1);
				time_quick_2 = time(NULL);
				clock_quick_2 = clock();
				printf ("\n");
				printf ("\nSteps quicksort: %d", steps_quick); 
				printf ("\nTime elapsed: %f\n", (float) 
					(clock_quick_1 - clock_quick_2));
				printf ("\nTime elapsed: %ld\n", (long) 
					(time_quick_1 - time_quick_2)/CLOCKS_PER_SEC);
				print_array(a);
				break;
			default:
				printf("Exiting from default");
				break;
		}
	} while (option <= 0 || option > 4);
}
